class Solution(object):
    def shiftingLetters(self, s, shifts):
        """
        :type s: str
        :type shifts: List[int]
        :rtype: str
        """
        n = len(shifts)
        for i in range(n - 2, -1, -1):
            shifts[i] += shifts[i + 1]
        out = []
        for i in range(n):
            out.append(chr((ord(s[i]) - ord('a') + shifts[i]) % 26 + ord('a')))
        return ''.join(out)



data = Solution()
s = "abc"
shifts = [3, 5, 9]
print(data.shiftingLetters(s, shifts))
